#include <ESP8266WiFi.h>
#include <WiFiClient.h>

#define STATE_BLUE 2

void SmartConfig()
{
  ESP.eraseConfig();
  WiFi.mode(WIFI_STA);
  WiFi.stopSmartConfig();
  WiFi.beginSmartConfig();
  while (1)
  {
    ESP.wdtFeed();
    delay(200);
    if (WiFi.smartConfigDone())
    {
      Serial.println("Get it");
      Serial.println("SSID:" + WiFi.SSID());
      Serial.println("PASW:" + WiFi.psk());
      delay(10000);
      WiFi.stopSmartConfig();
      break;
    }
  }
}
  
void setup() {
  Serial.begin(9600);
  pinMode(STATE_BLUE, OUTPUT);
  digitalWrite(STATE_BLUE, HIGH);
  SmartConfig();

  while (1)
  {
    if (WiFi.status() == WL_CONNECTED) break;
  }
  
  digitalWrite(STATE_BLUE, LOW);
}

void loop(){
  
}
